<template>
<div class="header">
   <div class="header-left">
    <div class="iconfont iconfanhui back-icon"></div>
   </div>
   <div class="header-input">
    <span class="iconfont iconsousuo"></span>
    输入城市/景点/主题
   </div>
   <router-link to="/city">
     <div class="header-right">
      {{this.city}}
      <span class="iconfont iconjiantou arrow-icon"></span>
     </div>
   </router-link>
</div>
</template>
<script>
import { mapState } from 'vuex' // 简便写法 代替 this.$store.state.city
export default {
  name: 'HomeHeader',
  computed: {
    ...mapState(['city']) // 展开运算符 利用映射关系  把state里面的city 映射到计算属性
  }
}
</script>

<style lang="stylus" scoped>
  @import "~styles/varibles.styl"
  //引入背景颜色，引入方法用了自定义路径名称，可以看笔记，同时因为不在根目录所以要加上波浪号
 .header
  display: flex
  line-height: .86rem
  color: #fff
  background-color: $bgColor
  .header-left
    width: .64rem
    float: left
    .back-icon
      text-align:center
      font-size:.4rem

  .header-input
    flex: 1
    background-color:#fff
    border-radius:.1rem
    height:.64rem
    margin-top: .12rem
    margin-left .2rem
    padding-left: .2rem
    color:#ccc
    line-height:.64rem

  .header-right
    min-width: 1.06rem  // 避免文字太长张开
    padding 0 .2rem
    float: right
    text-align: center
    color #fff
    .arrow-icon
      margin-left: -.03rem
      font-size:.24rem

</style>
